Skip to content

fix: avoid configuring root logger in mcpserver#2530

Open
HenryLee789 wants to merge 1 commit intomodelcontextprotocol:mainfrom
HenryLee789:codex/scope-mcp-logging
Open

fix: avoid configuring root logger in mcpserver#2530
HenryLee789 wants to merge 1 commit intomodelcontextprotocol:mainfrom
HenryLee789:codex/scope-mcp-logging

Conversation

@HenryLee789
Copy link
Copy Markdown

Summary

  • stop configure_logging() from calling logging.basicConfig() on the root logger
  • install the default handler only on the mcp logger namespace, leaving third-party libraries such as httpx outside FastMCP's INFO/RichHandler setup
  • keep propagation enabled so existing root handlers, pytest caplog, and user logging integrations still observe MCP warnings/errors

Fixes #2527.

Testing

  • uv run pytest tests/server/mcpserver/test_logging.py -q
  • uv run pytest tests/server/mcpserver -q
  • uv run --frozen ruff format --check src/mcp/server/mcpserver/utilities/logging.py tests/server/mcpserver/test_logging.py
  • uv run --frozen ruff check src/mcp/server/mcpserver/utilities/logging.py tests/server/mcpserver/test_logging.py
  • uv run --frozen pyright src/mcp/server/mcpserver/utilities/logging.py tests/server/mcpserver/test_logging.py
  • uv run --frozen --no-sync coverage report --include='src/mcp/server/mcpserver/utilities/logging.py'
  • uv run --frozen --no-sync strict-no-cover
  • git diff --check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FastMCP.__init__ clobbers root logger with INFO RichHandler — hangs stdio servers under back-pressure

1 participant